define([
  'vue'
],
  function (Vue) {
    function render () {
      new Vue({
        el: '#{{name}}-form',
        components: {
        },
        data () {
          return {
            form: {
            }
          }
        },
        created () {
          const id = window.CACHE_.id
          if(!id) return
          this.getdata(id)
        },
        methods: {
          validate(){
            return true
          },
          async getdata(id){
            return
            const res = await $.elApi(id)
            this.form = Object.assign({},this.form, res)
          },
          getpostdata(){
            return {
              ...this.form
            }
          },
          async save(){
            if(!this.validate()) return
            const data = this.getpostdata()
            let save
            if(this.form.id){
              save = $.elApi
            }else{
              save = $.elApi
            }
            await save(data)
            $.msg.success('保存成功')
            this.closeForm()
          },
        }
      })
    }
    return {
      init: render
    }
  })